//
//  NYSetPwdCompleteCell.m
//  NYTYY
//
//  Created by MinLison on 2017/12/12.
//  Copyright © 2017年 NYtyy. All rights reserved.
//

#import "NYSetPwdCompleteCell.h"

@implementation NYSetPwdCompleteCell

- (void)setUp
{
        [super setUp];
        
        self.button.cornerRadius = 20;
        self.button.backgroundColor = UIColorHex(0x3696FF);
        [self.button mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.center.equalTo(self.contentView);
                make.left.equalTo(self.contentView).offset(__WGWidth(15));
                make.right.equalTo(self.contentView).offset(-__WGWidth(15));
                CGFloat height = [[self class] heightForField:self.field width:0];
                make.height.mas_equalTo(__WGHeight(MIN(height, 40)));
        }];
        
        @weakify(self);
        [self adjustButtonEnable];
        [self.KVOController observe:NYUserManager keyPath:@keypath(NYUserManager,canResetPassword) options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionOld) block:^(id  _Nullable observer, id  _Nonnull object, NSDictionary<NSString *,id> * _Nonnull change) {
                @strongify(self);
                [self adjustButtonEnable];
        }];
}
- (void)adjustButtonEnable
{
        if (self.button.isEnabled != NYUserManager.canResetPassword) {
                self.button.enabled = NYUserManager.canResetPassword;
        }
}
@end
